import 'package:flutter/material.dart';
import '../../domain/models/device_model.dart';

/// 房间选择器组件
class RoomSelector extends StatelessWidget {
  final List<RoomModel> rooms;
  final String selectedRoom;
  final Function(String) onRoomSelected;

  const RoomSelector({
    Key? key,
    required this.rooms,
    required this.selectedRoom,
    required this.onRoomSelected,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container(
      height: 70,
      child: ListView.builder(
        scrollDirection: Axis.horizontal,
        itemCount: rooms.length,
        itemBuilder: (context, index) {
          final room = rooms[index];
          final isSelected = room.name == selectedRoom;
          
          return GestureDetector(
            onTap: () => onRoomSelected(room.name),
            child: Container(
              width: 70,
              margin: const EdgeInsets.symmetric(horizontal: 8),
              child: Column(
                mainAxisAlignment: MainAxisAlignment.center,
                children: [
                  Icon(
                    room.icon,
                    color: isSelected ? Colors.blue : Colors.grey,
                    size: 28,
                  ),
                  const SizedBox(height: 4),
                  Text(
                    room.name,
                    style: TextStyle(
                      color: isSelected ? Colors.blue : Colors.grey,
                      fontSize: 12,
                      fontWeight: isSelected ? FontWeight.bold : FontWeight.normal,
                    ),
                  ),
                ],
              ),
            ),
          );
        },
      ),
    );
  }
}